package com.mmy.fta.trade.server.dao.impl;

import com.mmy.fta.trade.server.dao.OrderDao;
import com.mmy.fta.trade.server.entity.OrderEntity;
import com.mmy.fta.trade.server.repository.OrderEntityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author qiang.lin
 * @since 2021/10/26
 */
@Service
public class OrderDaoImpl implements OrderDao {
    @Autowired
    OrderEntityMapper orderEntityMapper;

    @Override
    public List<OrderEntity> queryTransportOrderByDriver(String carrierOpenid) {
        return orderEntityMapper.queryTransportOrdersByDriver(carrierOpenid);
    }

    @Override
    public List<OrderEntity> queryTransportOrderByShipper(String consignorOpenId) {
        return orderEntityMapper.queryTransportOrdersByShipper(consignorOpenId);
    }

    @Override
    public List<OrderEntity> queryCanceledOrdersByDriver(String consignorUserId) {
        return orderEntityMapper.queryCanceledOrderOrdersByDriver(consignorUserId);
    }

    @Override
    public List<OrderEntity> queryCanceledOrdersByShipper(String consignorUserId) {
        return orderEntityMapper.queryCanceledOrderOrdersByShipper(consignorUserId);
    }

    @Override
    public List<OrderEntity> queryCompletedOrdersByDriver(String carrierOpenId) {
        return orderEntityMapper.queryCompletedOrdersByDriver(carrierOpenId);
    }

    @Override
    public List<OrderEntity> queryCompletedOrdersByShipper(String consignorUserId) {
        return orderEntityMapper.queryCompletedOrdersByShipper(consignorUserId);
    }

    @Override
    public int cancelOrderByDriver(String orderNumber,Date driverCancelTime, Date updateTime) {
        return orderEntityMapper.cancelOrderByDriver(orderNumber,driverCancelTime,updateTime);
    }

    @Override
    public int receiveOrderByShipper(String orderNumber, Date shipperReceiveTime, Date finishTime, Date updateTime) {
        return orderEntityMapper.receiveOrderByShipper(orderNumber, shipperReceiveTime, finishTime, updateTime);
    }

    @Override
    public int loadOrderByDriver(String orderNumber, Date driverLoadTime, Date updateTime) {
        return orderEntityMapper.loadOrderByDriver( orderNumber,  driverLoadTime,  updateTime);
    }

    @Override
    public int unloadOrderByDriver(String orderNumber, Date driverUnloadTime, Date updateTime) {
        return orderEntityMapper.unloadOrderByDriver(orderNumber,driverUnloadTime,updateTime);
    }

    @Override
    public int insertSelective(OrderEntity record) {
        return orderEntityMapper.insertSelective(record);
    }

    @Override
    public String selectCargoIdByOrderNumber(String orderNumber) {
        return orderEntityMapper.selectCargoIdByOrderNumber(orderNumber);
    }

    @Override
    public int insert(OrderEntity orderEntity) {
        return orderEntityMapper.insert(orderEntity);
    }

    @Override
    public OrderEntity queryOrderDetail(String orderNumber) {
        return orderEntityMapper.queryOrderDetail(orderNumber);
    }

    @Override
    public int republishCargo(String cargoId,Date updateTime) {
        return orderEntityMapper.republishCargo(cargoId,updateTime);
    }

    @Override
    public int agreeOrderByShipper(String orderNumber,  Date shipperAgreeTime, Date updateTime) {
        return orderEntityMapper.agreeOrderByShipper(orderNumber,shipperAgreeTime, updateTime);
    }

    @Override
    public int refuseOrderByShipper(String orderNumber, Date shipperRefuseTime,Date updateTime) {
        return orderEntityMapper.refuseOrderByShipper(orderNumber,shipperRefuseTime,updateTime);
    }

    @Override
    public int cancelOrderByShipper(String orderNumber, Date shipperCancelTime, Date updateTime) {
        return  orderEntityMapper.cancelOrderByShipper(orderNumber,shipperCancelTime,updateTime);
    }
}
